<template>
  <div class="Newsupply">
    <!--Header-->
    <div class="detPgHeader">
      <div class="detPgHeaderleft">
        <span class="side_1"></span>
        <span class="add_1">{{ title }}</span>
      </div>
      <el-button type="info" icon="el-icon-back" onclick="window.history.go(-1)">返回</el-button>
    </div>
    <!--Main-->
    <!--采购信息-->
    <div class=""
         style="width: 1600px;height: 420px;border-radius: 5px;background: white;margin: 0 auto;padding: 20px 45px">
      <span style="font-size: 16px;font-weight: 700;font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';">采购信息</span>
      <div class="" style="">
        <el-table :data="tableDataPurchInfo" height="300" style="margin: 10px 10px;" show-overflow-tooltip
                  :max-height="300" @selection-change="handleSelectionChange_Purch">
          <el-table-column type="selection"></el-table-column>
          <el-table-column label="序号" type="index" align="center" width="120px"></el-table-column>
          <el-table-column label="类型" align="center">
            <template v-slot="scope">
              <span v-if="scope.row.type==1">采购订单</span>
              <span v-if="scope.row.type==2">退货订单</span>
              <span v-if="scope.row.type==3">销售订单</span>
            </template>
          </el-table-column>
          <el-table-column label="产品图号" prop="productNumber" align="center"></el-table-column>
          <el-table-column label="产品名称" align="center" prop="productName"></el-table-column>
          <el-table-column label="入库总数" prop="number" align="center"></el-table-column>
          <!-- <el-table-column label="状态" prop="statue" align="center"></el-table-column>-->
          <!--<el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="dialogPurDetail=true">详情</el-button>
            </template>
          </el-table-column>
        </el-table>-->
        </el-table>
        <div
          style="width: 100%;height: 55px;display: flex;align-items:center;justify-content:center;display: -webkit-flex;">
          <el-button class="huizhongBT" style="" type="primary" size="" @click="summarySettlement">汇总结算</el-button>
        </div>
      </div>
    </div>
    <!--结算记录-->
    <div style="width: 1600px;height: 320px;border-radius: 5px;background: white;margin: 10px auto;padding: 20px 45px">
      <span style="font-size: 16px;font-weight: 700;font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';">结算记录</span>
      <div class="" style="">
        <el-table :data="tableDataPurchInfo_log" height="300" style="margin: 10px 10px;" show-overflow-tooltip
                  :max-height="300">
          <el-table-column label="序号" type="index" width="120" align="center"></el-table-column>
          <el-table-column label="供应商" prop="supplierName" align="center"></el-table-column>
          <el-table-column label="结算总额(元)" align="center" prop="moneySum"></el-table-column>
          <el-table-column label="生成日期" prop="createonTime" align="center">
            <template v-slot="scope">
              <span>{{ formatTime(scope.row.createonTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="状态" align="center" prop="status">
            <template slot-scope="scope">
              <span v-if="scope.row.status==1">待开票</span>
              <span v-if="scope.row.status==2">开票审核中</span>
              <span v-if="scope.row.status==3">待付款</span>
              <span v-if="scope.row.status==4">已完成</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center">
            <template slot-scope="scope">
              <el-button v-show="scope.row.status==3" type="primary" plain @click="operation(2,scope.row.id)">
                申请付款
              </el-button>
              <el-button v-show="scope.row.status==1" type="primary" @click="operation(1,scope.row.id)">执行
              </el-button>
              <el-button type="text" @click="getPurDetailLog(scope.row.id)">详情</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <!--==========================弹框汇总===========================-->
    <!--采购信息详情弹框-->
    <el-dialog
      title="title"
      :visible.sync="dialogPurDetail"
      width="50%"
      append-to-body
    >
      <div style="display: flex;align-content: center;justify-content: center">
        <div class="purInfo001" style="">
          <el-table :data="tableDataPurchInfoDetail"
                    height="300px"
                    :max-height="300"
                    :row-style="{height:'37px'}"
          >
            <el-table-column label="申请入库数量"></el-table-column>
            <el-table-column label="入库数量"></el-table-column>
            <el-table-column label="订单编号"></el-table-column>
            <el-table-column label="采购单号"></el-table-column>
            <el-table-column label="价格"></el-table-column>
          </el-table>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogPurDetail = false">取 消</el-button>
        <el-button type="primary" @click="dialogPurDetail = false">确 定</el-button>
      </div>
    </el-dialog>
    <!--结算单-->
    <el-dialog
      title="结算单"
      :visible.sync="dialogBill"
      width="50%"
      append-to-body
    >
      <div style="height: 70px">
        <el-form :inline="true" :model="fromDataHuiZhong" style="height: 100%">
          <el-form-item label="供应商名称">
            <el-input disabled v-model="fromDataHuiZhong.enterpriseName"></el-input>
          </el-form-item>
          <el-form-item label="联系人">
            <el-input disabled v-model="fromDataHuiZhong.contacts"></el-input>
          </el-form-item>
          <el-form-item label="联系方式">
            <el-input disabled v-model="fromDataHuiZhong.contactsPhone"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div style="display: flex;align-content: center;justify-content: center">
        <div class="purInfo001" style="">
          <el-table :data="tableDataHuiZhongBill"
                    height="300px"
                    :max-height="300"
                    :row-style="{height:'37px'}"
          >
            <el-table-column label="产品图号" prop="productTuhao" align="center"></el-table-column>
            <el-table-column label="产品名称" prop="productName" align="center"></el-table-column>
            <el-table-column label="单价" prop="price" align="center"></el-table-column>
            <el-table-column label="结算数量" prop="jiesuanShuliang" align="center">
              <template v-slot="scope">
                <span>{{ scope.row.caigouNumber - scope.row.tuihuoNuber }}</span>
              </template>
            </el-table-column>
            <el-table-column label="退货数量" prop="tuihuoNuber" align="center"></el-table-column>
            <el-table-column label="采购数量" prop="caigouNumber" align="center"></el-table-column>
            <el-table-column label="结算总额" prop="jiesuanMoney" align="center"></el-table-column>
          </el-table>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogBill = false">取 消</el-button>
        <el-button type="primary" @click="dialogBill = false||settlement()">确 定</el-button>
      </div>
    </el-dialog>
    <!--申请付款-->
    <el-dialog
      :title="shengqing"
      :visible.sync="applyToPay"
      width="60%"
      append-to-body
    >
      <!--供应商-->
      <div style="height: 70px">
        <el-form :inline="true" :model="fromDataSupplier" style="height: 100%">
          <el-form-item label="供应商名称">
            <el-input disabled v-model="fromDataSupplier.enterpriseName"></el-input>
          </el-form-item>
          <el-form-item label="联系人">
            <el-input disabled v-model="fromDataSupplier.contacts"></el-input>
          </el-form-item>
          <el-form-item label="联系方式">
            <el-input disabled v-model="fromDataSupplier.contactsPhone"></el-input>
          </el-form-item>
          <el-form-item label="总金额">
            <el-input disabled v-model="fromDataHuiZhong.moneySum"></el-input>
          </el-form-item>
        </el-form>
      </div>

      <!--填写的付款 金额-->
      <div v-show="operation_type==2" style="height: 70px; padding-top: 50px;">
        <el-form :inline="true" :model="fromDataHuiZhong" style="height: 100%">
          <el-form-item label="已付款金额">
            <el-input disabled style="width: 100px" v-model="fromDataHuiZhong.yifukuaiMonry"></el-input>
          </el-form-item>
          <el-form-item label="申请中金额">
            <el-input disabled style="width: 100px" v-model="fromDataHuiZhong.applyingMoney"></el-input>
          </el-form-item>
          <el-form-item label="剩余付款金额">
            <el-input disabled style="width: 100px" v-model="fromDataHuiZhong.shengyuMoney"></el-input>
          </el-form-item>
          <el-form-item label="本次付款金额"v-show="faifukuan>0" >
            <template v-slot="scope">
              <el-input @input="checkNowMoney()" style="width: 100px"
                        v-model="fromDataHuiZhong.JieSuanMoneyNow"></el-input>
            </template>
          </el-form-item>
        </el-form>
      </div>
      <div style="display: flex;align-content: center;justify-content: center;flex-wrap: wrap; padding-top: 25px">
        <div v-show="operation_type==1"
             style="font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';font-weight: 700;font-size: 14px;width: 100%;padding-top: 15px">
          开票操作 ：
          <el-button @click="addRow" type="primary" plain>新增</el-button>
        </div>
        <div v-show="operation_type==1" class="purInfo002" style="margin-top: 15px">
          <el-table :data="tableDataKaiPiao"
                    width="100%"
                    height="300px"
                    :max-height="150"
                    :row-style="{height:'37px'}"
          >
            <el-table-column type="index" width="150" align="center" label="序号"></el-table-column>
            <el-table-column prop="productName" width="150" label="票号" align="center">
              <template v-slot="scope">
                <el-input v-model="scope.row.piaoNumber"></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="orderTotalNum" label="开票时间" align="center">
              <template v-slot="scope">
                <el-date-picker
                  value-format="yyyy-MM-dd"
                  format="yyyy-MM-dd"
                  v-model="scope.row.kaipiaoTime"
                  type="date"
                  placeholder="选择日期">
                </el-date-picker>
              </template>
            </el-table-column>
            <el-table-column prop="returnNum" label="发票金额" align="center">
              <template v-slot="scope">
                <el-input v-model="scope.row.money" >
                </el-input>
              </template>
            </el-table-column>
            <el-table-column prop="totalSettle" label="操作" align="center">
              <template v-slot="scope">
                <el-button
                  type="danger"
                  icon="el-icon-delete"
                  @click="resetForm(scope)"
                  size="small"
                />
              </template>
            </el-table-column>

          </el-table>
        </div>
        <!--================================产品=================================-->
        <div
          style="font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';font-weight: 700;font-size: 14px;width: 100%;margin-top: 15px">
          产品详情：
        </div>
        <div style="margin-top: 15px;width: 100%">
          <el-table :data="tableDataProduct"
                    height="300px"
                    :max-height="150"
                    :row-style="{height:'37px'}"
          >
            <el-table-column prop="productTuhao" align="center" label="产品图号"/>
            <el-table-column prop="productName" label="产品名称" align="center"/>
            <el-table-column prop="caigouNumber" label="采购数量" align="center"/>
            <el-table-column prop="tuihuoNuber" label="退货数量" align="center"/>
            <el-table-column prop="jiesuanShuliang" label="可结算总量" align="center"/>
            <el-table-column prop="thisJieSuan" label="本次结算总量" align="center"/>
            <el-table-column prop="price" label="单价(元)" align="center"/>
            <el-table-column prop="jiesuanMoney" label="结算金额(元)" align="center"/>
          </el-table>
        </div>
        <!--======================付款记录========================================-->
        <div v-show="operation_type==2"
             style="font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';font-weight: 700;font-size: 14px;width: 100%;">
          付款记录：
        </div>
        <div v-show="operation_type==2" class="purInfo002">
          <el-table :data="tableDataFuKuanDetail"
                    height="300px"
                    :max-height="150"
                    :row-style="{height:'37px'}"
          >
            <el-table-column type="index" align="center" width="200" label="序号"/>
            <el-table-column prop="fukuanMoney" label="付款金额" align="center"/>
            <el-table-column prop="status" label="状态" align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.status==1">待审核</span>
                <span v-if="scope.row.status==2" style="color: red">驳回</span>
                <span v-if="scope.row.status==3">已完成</span>
              </template>
            </el-table-column>
            <el-table-column label="付款时间" align="center">
              <template v-slot="scope">
                <div>{{ formatTime(scope.row.createonTime) }}</div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!--======================发票记录========================================-->
        <div v-show="operation_type==1"
             style="font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';font-weight: 700;font-size: 14px;width: 100%;margin-top: 15px">
          发票记录：
        </div>
        <div v-show="operation_type==1" class="purInfo002" style="margin-top: 15px">
          <el-table :data="tableDataKaiPiaoLog"
                    height="300px"
                    :max-height="150"
                    :row-style="{height:'37px'}"
          >
            <el-table-column type="index" align="center" label="序号" width="150"/>
            <el-table-column prop="piaoNumber" label="票号" align="center"/>
            <el-table-column prop="money" label="票号总额" align="center"/>
            <el-table-column prop="status" label="状态" align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.status==1">待审核</span>
                <span v-if="scope.row.status==2" style="color: red">驳回</span>
                <span v-if="scope.row.status==3">已完成</span>
              </template>
            </el-table-column>
            <el-table-column prop="kaipiaoTime" label="开票时间" align="center">
              <template v-slot="scope">
                <div>{{ formatTime(scope.row.kaipiaoTime) }}</div>
              </template>

            </el-table-column>
          </el-table>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="applyToPay = false">取 消</el-button>
        <el-button type="primary" @click="applyOperation()"  v-show="(operation_type==1)||(operation_type==2&&faifukuan>0)">确 定</el-button>
      </div>
    </el-dialog>
    <!--详情-->
    <el-dialog
      title="详情"
      :visible.sync="dialog_detail"
      width="60%"
      append-to-body
    >
      <!--供应商-->
      <div style="height: 70px">
        <el-form :inline="true" :model="fromDataSupplier" style="height: 100%">
          <el-form-item label="供应商名称">
            <el-input disabled v-model="fromDataSupplier.enterpriseName"></el-input>
          </el-form-item>
          <el-form-item label="联系人">
            <el-input disabled v-model="fromDataSupplier.contacts"></el-input>
          </el-form-item>
          <el-form-item label="联系方式">
            <el-input disabled v-model="fromDataSupplier.contactsPhone"></el-input>
          </el-form-item>
          <el-form-item label="总金额">
            <el-input disabled v-model="fromDataHuiZhong.moneySum"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <!--发票记录-->
      <div
        style="font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';font-weight: 700;font-size: 14px;width: 100%;padding-top: 45px">
        发票记录：
      </div>
      <div class="purInfo002" style="margin-top: 15px">
        <el-table :data="tableDataKaiPiaoLog"
                  height="300px"
                  :max-height="150"
                  :row-style="{height:'37px'}"
        >
          <el-table-column type="index" align="center" label="序号" width="150"/>
          <el-table-column prop="piaoNumber" label="票号" align="center"/>
          <el-table-column prop="money" label="票号总额" align="center"/>
          <el-table-column prop="kaipiaoTime" label="开票时间" align="center">
            <template v-slot="scope">
              <div>{{ formatTime(scope.row.kaipiaoTime) }}</div>
            </template>

          </el-table-column>
          <el-table-column prop="status" label="状态" align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.status==1" >待审核</span>
                <span v-if="scope.row.status==2" style="color: red">驳回</span>
                <span v-if="scope.row.status==3">已通过</span>
              </template>
          </el-table-column>
        </el-table>
      </div>
      <!--付款记录-->
      <div v-show="operation_type==2"
           style="font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';font-weight: 700;font-size: 14px;width: 100%;">
        付款记录：
      </div>
      <div class="purInfo002" v-show="operation_type==2">
        <el-table :data="tableDataFuKuanDetail"
                  height="300px"
                  :max-height="150"
                  :row-style="{height:'37px'}"
        >
          <el-table-column type="index" align="center" width="200" label="序号"/>
          <el-table-column prop="fukuanMoney" label="付款金额" align="center"/>
          <el-table-column label="付款时间" align="center">
            <template v-slot="scope">
              <div>{{ formatTime(scope.row.createonTime) }}</div>
            </template>
          </el-table-column>
          <el-table-column prop="status" label="状态" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.status==1">待审核</span>
              <span v-if="scope.row.status==2" style="color: red">驳回</span>
              <span v-if="scope.row.status==3">已通过</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialog_detail = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import axios from "axios";

export default {
  inject: ['reload'],
  name: "SettlementDetail",
  components: {},
  data() {
    return {
      ids: [],
      title: "结算详情",
      tableDataFuKuanDetail: [],//付款记录
      tableDataKaiPiaoLog: [],//开票记录
      tableDataProduct: [],//产品集合
      tableDataKaiPiao: [],//开票集合
      tableDataFaPiao: [],
      operation_type: 0,
      fromDataSupplier: {},
      tableDataPurchInfo: [],//采购单信息
      tableDataPurchInfo_log: [],
      tableDataPurchInfoDetail: [{}, {}, {}, {}, {}, {}, {}, {}],//采购单详情
      tableDataHuiZhongBill: [{}, {}, {}, {}],
      tableDataRawDetail: [{
        tuHao: "HHHSDSDSD",
        productName: "sss",
        orderTotalNum: "2222",
        returnNum: "2323",
        keJieSuan: 2000,
        thisJieSuan: 333,
        price: 222.4,
        totalSettle: 444
      }, {}, {}, {}, {}, {},],
      /*弹框*/
      dialog_detail: false,
      dialogPurDetail: false,
      dialogBill: false,//结算单
      applyToPay: false,
      multipleSelection_Pruch: [],
      fromDataHuiZhong: {supplierName: "jaja", contacter: "dsd", contractWay: "18015348998", JieSuanMoneyNow: 0},
      faifukuan:"",
      shengqing:"申请开票"
    };
  },
//监听属性 类似于data概念",
  computed: {
    autoHeightTable() {
      return document.documentElement.scrollHeight - 251 - 78;
    }
  },
//监控data中的数据变化",
  watch: {},
//方法集合",
  methods: {
    checkNowMoney() {
      if (this.fromDataHuiZhong.shengyuMoney < this.fromDataHuiZhong.JieSuanMoneyNow) {
        this.$message.error("填写金额过大");
        this.fromDataHuiZhong.JieSuanMoneyNow = 0
        return;
      }

    },
    //动态增加行
    addRow() {
      const list = {};
      this.tableDataKaiPiao.push(list);
    },
    //动态删除行
    resetForm(e) {
      this.tableDataKaiPiao.splice(e.$index, 1);
    },
    //最终开始提交
    applyOperation: function () {
      if (this.operation_type == 1) {//走执行的按钮
        let param = []
        let a = 0
        this.tableDataKaiPiao.forEach(e => {

          let aa = {
            "createonTime": "",
            "id": 0,
            "kaipiaoTime": "",
            "logId": this.fromDataHuiZhong.logId,
            "money": 0,
            "piaoNumber": "",
            "shenghemessageId": 0,
            "status": 0
          };
          a = parseFloat(e.money) + a
          aa.money = e.money
          aa.kaipiaoTime = e.kaipiaoTime
          aa.piaoNumber = e.piaoNumber
          param.push(aa)
        })
        if (a != this.fromDataHuiZhong.moneySum) {
          this.$message.error("开票金额必须等于总金额");
          return
        }

        let message = JSON.parse(localStorage.getItem("message"));
        axios.post("/JX_java/procurement/supplier/zhixing?userId=" + message.Id, param).then(res => {
          console.log(res.data.data)
          if (res.data.data == "操作成功") {
            this.$message.success(res.data.data);
            this.applyToPay = false;
            this.getList(this.$route.query.id);
          } else {
            this.$message.error(res.data.data);
          }
        })
      } else if (this.operation_type == 2) {//走付款的按钮
        console.log(2232323)
        let message = JSON.parse(localStorage.getItem("message"));
        axios.get("/JX_java/procurement/supplier/addfukuan?money=" + this.fromDataHuiZhong.JieSuanMoneyNow + "&&userId=" + message.Id + "&&logId=" + this.fromDataHuiZhong.logId).then(res => {
          if (res.data.data == "操作成功") {
            this.$message.success(res.data.data);
            this.applyToPay = false;
            this.getList(this.$route.query.id);
          } else {
            this.$message.error(res.data.data);
          }
        })
        /*this.fromDataHuiZhong.yifukuaiMonry
        this.fromDataHuiZhong.shengyuMoney
        this.fromDataHuiZhong.daoqiTime
        this.fromDataHuiZhong.JieSuanMoneyNow*/
      }
    },
    //点击查看
    operation(type, id) {
      if (type == 1) {//执行   开票
        this.shengqing="申请开票",
        this.operation_type = 1
        axios.get("/JX_java/procurement/supplier/zhixing?logId=" + id).then(res => {
          console.log(res.data.data)//tableDataProduct
          this.tableDataProduct = res.data.data.jieSuanSupplierProducts
          this.tableDataKaiPiaoLog = res.data.data.kaipiaos
          this.fromDataSupplier = res.data.data.supplierTb
          this.fromDataHuiZhong.moneySum = res.data.data.moneySum
          this.fromDataHuiZhong.logId = id
          this.applyToPay = true
        })
      }
      if (type == 2) {//付款
        this.shengqing="申请付款",
        this.operation_type = 2
        axios.get("/JX_java/procurement/supplier/zhixing?logId=" + id).then(res => {
          console.log(res.data.data)
          this.tableDataProduct = res.data.data.jieSuanSupplierProducts
          this.fromDataHuiZhong.moneySum = res.data.data.moneySum
          this.fromDataSupplier = res.data.data.supplierTb
          this.fromDataHuiZhong.yifukuaiMonry = res.data.data.yifukuaiMonry
          this.fromDataHuiZhong.shengyuMoney = res.data.data.shengyuMoney
          this.faifukuan = this.fromDataHuiZhong.shengyuMoney
          console.log(this.faifukuan)
          this.fromDataHuiZhong.daoqiTime = res.data.data.daoqiTime
          this.fromDataHuiZhong.JieSuanMoneyNow = res.data.data.JieSuanMoneyNow
          this.fromDataHuiZhong.applyingMoney = res.data.data.applyingMoney
          this.tableDataFuKuanDetail = res.data.data.fukuans
          this.fromDataHuiZhong.logId = id
          this.applyToPay = true
        })


      }
    },
    //获取结算记录的详情
    getPurDetailLog(id) {
      console.log(id)
      axios.get("/JX_java/procurement/supplier/zhixing?logId=" + id).then(res => {
        console.log(res.data.data)//
        this.fromDataHuiZhong = {}
        this.fromDataSupplier = {}
        this.tableDataFuKuanDetail = []
        this.tableDataKaiPiaoLog = []
        this.fromDataHuiZhong.moneySum = res.data.data.moneySum
        this.tableDataFuKuanDetail = res.data.data.fukuans
        this.tableDataKaiPiaoLog = res.data.data.kaipiaos
        this.fromDataSupplier = res.data.data.supplierTb
        this.dialog_detail = true
      })
    },
    //时间格式化
    formatTime(data){
      return data==null?"":data.substring(0, 10);
    },
//格式化时间
    renderTime(date) {
      const dateee = new Date(date).toJSON();
      if (date == null) {
        return "---";
      } else {
        return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
      }
    },
    //开始结算
    settlement() {
      let total = 0
      this.tableDataHuiZhongBill.forEach(e => {
        total = total + e.jiesuanMoney
      })
      if (total <= 0) {
        this.$message.error("结算总额异常,无法结算")
        return
      }
      let param = {
        "ids": this.ids,
        "products": [],
        "supplierId": this.fromDataHuiZhong.id,
        "supplierName": this.fromDataHuiZhong.enterpriseName,
        "supplierTb": null
      }
      this.tableDataHuiZhongBill.forEach(e => {
        let item = {
          "caigouNumber": 0,
          "id": 0,
          "jiesuanMoney": 0,
          "jiesuanShuliang": 0,
          "logId": 0,
          "numberSum": 0,
          "price": 0,
          "productName": "",
          "productTuhao": "",
          "supplierId": 0,
          "tuihuoNuber": 0,
          "type": 0
        }
        item.caigouNumber = e.caigouNumber
        item.id = null
        item.jiesuanMoney = e.jiesuanMoney
        item.jiesuanShuliang = e.jiesuanShuliang
        item.logId = e.logId
        item.numberSum = e.numberSum
        item.price = e.price
        item.productName = e.productName
        item.productTuhao = e.productTuhao
        item.supplierId = e.supplierId
        item.tuihuoNuber = e.tuihuoNuber
        item.type = e.type
        param.products.push(item)
      })
      axios.post("/JX_java/procurement/supplier/addJieSuanLog", param).then(res => {
        if (res.data.data == "操作成功") {
          this.$message.success(res.data.data);

          this.reload();
        } else {
          this.$message.error(res.data.data);
        }

      })
    },
    getList(id) {
      axios.get("/JX_java/procurement/supplier/gerJiesuanList?supplierId=" + id).then(res => {
        console.log(res.data.data)
        this.tableDataPurchInfo = res.data.data.warehouseLogs
        this.tableDataPurchInfo_log = res.data.data.jieSuanLogs
      })
    },
    //汇总结算
    summarySettlement() {
      if (this.multipleSelection_Pruch.length == 0) {
        this.$message.error("对不起！请至少选择一条采购信息");
        return;
      } else {
        let bb = []
        this.multipleSelection_Pruch.forEach(e => {
          let a = 0;
          a = e.id;
          bb.push(a)
        })
        axios.post("/JX_java/procurement/supplier/getJiesuanDetails", bb).then(res => {
          console.log(res.data.data)
          this.ids = res.data.data.ids
          this.tableDataHuiZhongBill = res.data.data.products
          this.fromDataHuiZhong = res.data.data.supplierTb
          this.dialogBill = true;
        })
      }
      //
    },

    handleSelectionChange_Purch(val) {
      this.multipleSelection_Pruch = val;
      console.log(this.multipleSelection_Pruch)
    },
  },
//生命周期 - 创建之前",数据模型未加载,方法未加载,html模板未加载
  beforeCreate() {
  },
//生命周期 - 创建完成（可以访问当前this实例）",数据模型已加载，方法已加载,html模板已加载,html模板未渲染
  created() {
    this.getList(this.$route.query.id);
    console.log(this.faifukuan,111111111111)
  },
//生命周期 - 挂载之前",html模板未渲染
  beforeMount() {
  },
//生命周期 - 挂载完成（可以访问DOM元素）",html模板已渲染
  mounted() {
  },
//生命周期 - 更新之前",数据模型已更新,html模板未更新
  beforeUpdate() {
  },
//生命周期 - 更新之后",数据模型已更新,html模板已更新
  updated() {
  },
//生命周期 - 销毁之前",
  beforeDestroy() {
  },
//生命周期 - 销毁完成",
  destroyed() {
  },
//如果页面有keep-alive缓存功能，这个函数会触发",
  activated() {
  },
}
</script>

<style lang="scss" scoped>
@import "@/assets/scss/base.scss";

.Newsupply {
  border-top: 1px solid transparent;
  animation: fade-in; /*动画名称*/
  animation-duration: 0.4s; /*动画持续时间*/
  -webkit-animation: fade-in 0.4s; /*针对webkit内核*/
}

@keyframes fade-in {
  0% {
    opacity: 0;
  }
  /*初始状态 透明度为0*/
  40% {
    opacity: 0;
  }
  /*过渡状态 透明度为0*/
  100% {
    opacity: 1;
  }
  /*结束状态 透明度为1*/
}

@-webkit-keyframes fade-in { /*针对webkit内核*/
  0% {
    opacity: 0;
  }
  40% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.purInfo001 {
  display: inline-block;
  height: 300px;
  width: 100%;
  border-top: 1px solid rgb(204, 204, 204);
  border-bottom: 1px solid rgb(204, 204, 204);
}

.purInfo002 {
  display: inline-block;

  width: 100%;
  border-top: 1px solid rgb(204, 204, 204);
  border-bottom: 1px solid rgb(204, 204, 204);
}

.huizhongBT {
  width: 133px;
  height: 50px;
}

.Newsupply .detPgHeader {
  border: 1px solid transparent;
  box-sizing: border-box;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  margin-bottom: 10px;
}

.Newsupply .detPgHeader .side_1 {
  width: 5px;
  height: 16px;
  background-color: $Header_color;
  display: inline-block;
}

.Newsupply .detPgHeader .add_1 {
  margin-left: 5px;
  font-size: 18px;
  font-weight: 400;
}
</style>
